package org.example.blog.service.impl;

import org.example.blog.Mapper.HistoryMapper;
import org.example.blog.pojo.History;
import org.example.blog.service.HistoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.util.List;

@Service
public class HistoryServiceImpl implements HistoryService {
    @Autowired
    private HistoryMapper historyMapper;

    @Override
    public List<History> list() {
        return historyMapper.list();
    }

    @Override
    public List<History> search( String name) {
        return historyMapper.search(name);
    }

    @Override
    public void add(History history) {
        history.setUpdateTime(LocalDateTime.now());
        historyMapper.insert(history);
    }

    @Override
    public void delete(Integer id) {
        historyMapper.deleteById(id);
    }
}